package com.cby.library.common.base

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData

open class BaseViewModel(application: Application) : AndroidViewModel(application) {

    //页面状态变化
    val pageStatusData = MutableLiveData<PageStatus>()

    fun showLoading() {
        pageStatusData.postValue(PageStatus.loading())
    }

    fun showContent() {
        pageStatusData.postValue(PageStatus.success())
    }

    fun showEmpty() {
        pageStatusData.postValue(PageStatus.empty(""))
    }

    fun showError(errorMsg: String) {
        pageStatusData.postValue(PageStatus.error(errorMsg))
    }

}